package cn.edu.cdu.health.common;

import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

//@ResponseBody
//@ControllerAdvice

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = BizException.class)
    public R handleBizException(BizException e) {

        return R.failed(e.getMessage());

    }

    @ExceptionHandler(value = Exception.class)
    public R handleException(Exception e) {

        //log.error(e.toString());
        //log.error(e.getMessage());
        e.printStackTrace();

           /* StackTraceElement[] stackTraceElements = e.getStackTrace();
            for (StackTraceElement stackTraceElement : stackTraceElements) {
            log.error(stackTraceElement.toString());
        }*/
        return R.failed("服务器开小差了,请稍后再试");


    }
}
